#ifndef __MOTIONSENSOR_H__
#define __MOTIONSENSOR_H__
//#include "MotionSensor_ext.h"
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/sched.h>
//#include <linux/kthread.h>
#include "hi_comm_motionsensor.h"

//#define MNGBUFF_ENABLE

#define MSENSOR_DEV_NAME "motionsensor_chip"


#define DATA_RATE_RESERVED      (0x00)
#define DATA_RATE_25HZ          (0x06)
#define DATA_RATE_50HZ          (0x07)
#define DATA_RATE_100HZ         (0x08)
#define DATA_RATE_200HZ         (0x09)
#define DATA_RATE_400HZ         (0x0A)
#define DATA_RATE_800HZ         (0x0B)
#define DATA_RATE_1600HZ        (0x0C)
#define DATA_RATE_3200HZ        (0x0D)

#define GYRO_FULL_SCALE_RANGE_250DPS    (250 << 10)
#define GYRO_FULL_SCALE_RANGE_500DPS    (500 << 10)
#define GYRO_FULL_SCALE_RANGE_1KDPS     (1000 << 10)
#define GYRO_FULL_SCALE_RANGE_2KDPS     (2000 << 10)
#define GYRO_FULL_SCALE_RANGE_31DPS     ((3125  << 10) / 100)
#define GYRO_FULL_SCALE_RANGE_62DPS     ((625 << 10) / 10)
#define GYRO_FULL_SCALE_RANGE_125DPS    (125 << 10)

#define ACCEL_UI_FULL_SCALE_RANGE_2G   (1)
#define ACCEL_UI_FULL_SCALE_RANGE_4G   (2)
#define ACCEL_UI_FULL_SCALE_RANGE_8G   (3)
#define ACCEL_UI_FULL_SCALE_RANGE_16G  (4)

#define ACCEL_OIS_FULL_SCALE_RANGE_1G  (5)
#define ACCEL_OIS_FULL_SCALE_RANGE_2G  (6)
#define ACCEL_OIS_FULL_SCALE_RANGE_4G  (7)
#define ACCEL_OIS_FULL_SCALE_RANGE_8G  (8)

#define MOTIONSENSOR_MAX_TEMP  (85)
#define MOTIONSENSOR_MIN_TEMP  (-40)


typedef enum hiMOTIONSENSOR_GYRO_OUTPUT_DATA_RATE_E
{
    GYRO_OUTPUT_DATA_RATE_32KHZ     = 32000,
    GYRO_OUTPUT_DATA_RATE_8KHZ      = 8000,
    GYRO_OUTPUT_DATA_RATE_3200HZ    = 3200,
    GYRO_OUTPUT_DATA_RATE_1600HZ    = 1600,
    GYRO_OUTPUT_DATA_RATE_800HZ     = 800,
    GYRO_OUTPUT_DATA_RATE_400HZ     = 400,
    GYRO_OUTPUT_DATA_RATE_200HZ     = 200,
    GYRO_OUTPUT_DATA_RATE_100HZ     = 100,
    GYRO_OUTPUT_DATA_RATE_50HZ      = 50,
    GYRO_OUTPUT_DATA_RATE_25HZ      = 25,
    GYRO_OUTPUT_DATA_RATE_UNDER_1KHZ,
    GYRO_OUTPUT_DATA_RATE_BUTT
}MOTIONSENSOR_GYRO_OUTPUT_DATA_RATE_E;



typedef enum hiMOTIONSENSOR_GYRO_BAND_WIDTH_E
{
    GYRO_BAND_WIDTH_5HZ,
    GYRO_BAND_WIDTH_10HZ,
    GYRO_BAND_WIDTH_20HZ,
    GYRO_BAND_WIDTH_41HZ,
    GYRO_BAND_WIDTH_92HZ,
    GYRO_BAND_WIDTH_184HZ,
    GYRO_BAND_WIDTH_250HZ,
    GYRO_BAND_WIDTH_3600HZ,
    GYRO_BAND_WIDTH_8800HZ,
    GYRO_BAND_WIDTH_BUTT
}MOTIONSENSOR_GYRO_BAND_WIDTH_E;


typedef enum hiMOTIONSENSOR_ACCEL_OUTPUT_DATA_RATE_E
{
    ACCEL_OUTPUT_DATA_RATE_4KHZ     = 4000,
    ACCEL_OUTPUT_DATA_RATE_1KHZ     = 1000,
    ACCEL_OUTPUT_DATA_RATE_1600HZ   = 1600,
    ACCEL_OUTPUT_DATA_RATE_800HZ    = 800,
    ACCEL_OUTPUT_DATA_RATE_400HZ    = 400,
    ACCEL_OUTPUT_DATA_RATE_200HZ    = 200,
    ACCEL_OUTPUT_DATA_RATE_100HZ    = 100,
    ACCEL_OUTPUT_DATA_RATE_50HZ     = 50,
    ACCEL_OUTPUT_DATA_RATE_25HZ     = 25,
    ACCEL_OUTPUT_DATA_RATE_UNDER_1KHZ,
    ACCEL_OUTPUT_DATA_RATE_BUTT
}MOTIONSENSOR_ACCEL_OUTPUT_DATA_RATE_E;


typedef enum hiMOTIONSENSOR_GYRO_FULL_SCALE_RANGE_E
{
    GYRO_FULL_SCALE_SET_250DPS  = 250 << 10,
    GYRO_FULL_SCALE_SET_500DPS  = 500 << 10,
    GYRO_FULL_SCALE_SET_1KDPS   = 1000 << 10,
    GYRO_FULL_SCALE_SET_2KDPS   = 2000 << 10,
    GYRO_FULL_SCALE_SET_31DPS   = (3125 << 10) / 100,
    GYRO_FULL_SCALE_SET_62DPS   = (625 << 10) / 10,
    GYRO_FULL_SCALE_SET_125DPS  = 125 << 10,
    GYRO_FULL_SCALE_SET_BUTT
}MOTIONSENSOR_GYRO_FULL_SCALE_RANGE_E;

typedef enum hiMOTIONSENSOR_ACCEL_UI_FULL_SCALE_RANGE_E
{
    ACCEL_UI_FULL_SCALE_SET_2G  = 2 << 10,
    ACCEL_UI_FULL_SCALE_SET_4G  = 4 << 10,
    ACCEL_UI_FULL_SCALE_SET_8G  = 8 << 10,
    ACCEL_UI_FULL_SCALE_SET_16G = 16 << 10,
    ACCEL_UI_FULL_SCALE_SET_BUTT
}MOTIONSENSOR_ACCEL_UI_FULL_SCALE_RANGE_E;

typedef enum hiMOTIONSENSOR_ACCEL_OIS_FULL_SCALE_RANGE_E
{
    ACCEL_OIS_FULL_SCALE_SET_1G = 1,
    ACCEL_OIS_FULL_SCALE_SET_2G = 2,
    ACCEL_OIS_FULL_SCALE_SET_4G = 4,
    ACCEL_OIS_FULL_SCALE_SET_8G = 8,
    ACCEL_OIS_FULL_SCALE_SET_BUTT
}MOTIONSENSOR_ACCEL_OIS_FULL_SCALE_RANGE_E;

typedef enum hiMOTIONSENSOR_ACCEL_BAND_WIDTH_E
{
    ACCEL_BAND_WIDTH_5HZ,
    ACCEL_BAND_WIDTH_10HZ,
    ACCEL_BAND_WIDTH_21HZ,
    ACCEL_BAND_WIDTH_44HZ,
    ACCEL_BAND_WIDTH_99HZ,
    ACCEL_BAND_WIDTH_218HZ,
    ACCEL_BAND_WIDTH_420HZ,
    ACCEL_BAND_WIDTH_1046HZ,
    ACCEL_BAND_WIDTH_BUTT
}MOTIONSENSOR_ACCEL_BAND_WIDTH_E;


typedef enum hiTRIGER_MODE_E
{
    TRIGER_TIMER = 0,
    TRIGER_EXTERN_INTERRUPT,
    TRIGER_BUTT
} TRIGER_MODE_E;

typedef struct hiTIMER_CONFIG_S
{
    hi_u32 u32interval;//unit :us
} TIMER_CONFIG_S;

typedef struct hiEXTERN_INTERRUPT_CONFIG_S
{
    hi_u32 u32Interrupt_num;
} EXTERN_INTERRUPT_CONFIG_S;


typedef union hiTRIGER_INFO_U
{
    TIMER_CONFIG_S stTimerConfig;
    EXTERN_INTERRUPT_CONFIG_S stExternInterruptConfig;
} TRIGER_INFO_U;

typedef struct hiTRIGER_CONFIG_S
{
    TRIGER_MODE_E eTrigerMode;
    TRIGER_INFO_U uTrigerInfo;
} TRIGER_CONFIG_S;


extern hi_msensor_param  *MotionSensorStatus;


#define  print_info(fmt, arg...)   \
    do{  \
            printk("fun:%s,%d "fmt, __func__,__LINE__, ##arg);  \
        }while(0)


//hi_s32 MOTIONSENSOR_GetData(hi_msensor_attr attr, hi_msensor_data* pstIMUdata);

#endif




